package com.ctgu.project.controller;

import com.ctgu.project.service.UsersService;
import com.ctgu.project.utils.ApiResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @ClassName UserController
 * @Author Alex2
 * @Date 2025/2/25 10:35
 **/
@RestController
@RequestMapping("/api/users")
public class UserController {

    @Autowired
    private UsersService usersService;

    /**
     * @Author: Alex
     * @Description: 用户签到
     */
    // http://localhost:8080/api/users/sign/1
    @GetMapping("/sign/{userId}")
    public ApiResult sign(@PathVariable("userId") Integer userId) {
        return usersService.sign(userId);
    }

    /**
     * @Author: Alex
     * @Description: 获取连续签到天数
     */
    // http://localhost:8080/api/users/getSignCount/1
    @GetMapping("/getSignCount/{userId}")
    public ApiResult getSignCount(@PathVariable("userId") Integer userId) {
        return usersService.getSignCount(userId);
    }
}